<style>
	.btn{
		height: 28px;
        line-height: 28px;
        margin: 0px 25px 0;
        padding: 0px 15px;
        border: 1px solid #dedede;
        color: #FFFFFF;
        border-radius: 2px;
        font-weight: 400;
        cursor: pointer;
        text-decoration: none;
        background: #5cb85c;
        border-color: ##5cb85c;
	}
	.btn:hover{
		color: #FFFFFF;
	}
	.btn:link{
		color: #FFFFFF;
	}
</style>
<{include file="tpl/filter.tpl"}>
<div>
	<!--<input class="label-success pull-left" type="checkbox" id="all" />&nbsp;<span id="aa">全选</span>
	<a href="javascript:;" id="synchro" name="synchro" class="btn">同步</a>-->
    <a class="label-success pull-right" style="color: #fff; padding: 0 4px;" href="<{PubFunc::buildUrl('/oss/?r=giftBag/add')}>">
        <i class="fa fa-plus"></i> 添加礼包
    </a>
</div>
	
<{include file="tpl/grid.tpl"}>
	


<script>
	$(function(){
		/**全选/全不选**/
		$(".iCheck-helper").click(function(){
			var state = $(".icheckbox_minimal-purple").attr('aria-checked');
            if(state == 'true') {
                $("input[name='id']").prop("checked", "checked");
            }else{
                $("input[name='id']").prop("checked", false);
            }
		});
		
		var options = $("[name='id']");
        $("input[name='id']").click(function() {
            var i = $("input[name='id']:checked");
            if(i.length == options.length) { 
            	$(".icheckbox_minimal-purple").prop('aria-checked',true);
            	$(".icheckbox_minimal-purple").addClass('checked');
            } else { 
                $(".icheckbox_minimal-purple").prop('aria-checked',false);
            	$(".icheckbox_minimal-purple").removeClass('checked');
            }
        });
        
        
        /**同步**/
        $('a[name="synchro"]').click(function(){
    		var arr = new Array();
            $("input[name='id']:checkbox[checked]").each(function(i){
                arr[i] = $(this).val();
            });
            var ids = arr.join(",");
            console.log(ids);
            if(ids == ""){
            	layer.msg('请先选择要同步的数据！', {icon: 2,time: 3000});
            	return false;
            }
    		$url = '?r=noticeSet/synchro&g=mango&ids='+ids;
    		layer.open({
    			skin: 'layui-layer-molv'
    			,type: 2
    			,area: ['750px', '600px']
    			,title:'同步'
    			,content: $url
    		});
        });   
		
	});
</script>